﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DropDownList2.Items.Add("福建省");
                DropDownList2.Items.Add("浙江省");
                DropDownList2.Items.Add("广东省");
                DropDownList3.Items.Add("龙岩");
                DropDownList3.Items.Add("厦门");
                DropDownList3.Items.Add("福州");
            }
        }

        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
        {
            string str = DropDownList2.SelectedValue;
            DropDownList3.Items.Clear();
            if (str == "福建省")
            {
                DropDownList3.Items.Add("龙岩");
                DropDownList3.Items.Add("厦门");
                DropDownList3.Items.Add("福州");
            }
            else if (str == "浙江省")
            {
                DropDownList3.Items.Add("金华");
                DropDownList3.Items.Add("温州");
                DropDownList3.Items.Add("嘉兴");
            }
            else
            {
                DropDownList3.Items.Add("深圳");
                DropDownList3.Items.Add("广州");
                DropDownList3.Items.Add("东莞");
            }
        }

        protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            if (FileUpload1.HasFile)
            {
                string str1 = FileUpload1.FileName;
                if (str1.EndsWith(".jpg") || str1.EndsWith(".png") || str1.EndsWith("jpeg"))
                {
                    string url = Server.MapPath("/img/" + str1);
                    FileUpload1.SaveAs(url);
                    Image1.ImageUrl = "/img/" + str1;
                    Image1.Visible = true;
                    Label5.Text = "上传成功！";
                }
                else
                {
                    Label5.Text = "格式错误！";
                }
            }
            else
            {
                Label5.Text = "文件为空或上传有误！";
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Label10.Text = $"姓名：{TextBox1.Text}；性别：{RadioButtonList1.SelectedValue}；爱好：{TextBox3.Text}；籍贯：{DropDownList2.SelectedValue}.{DropDownList3.SelectedValue}；其他信息：{TextBox4.Text}";
        }
    }
}